//
//  WKLoadWalletCell3.m
//  ourToken
//
//  Created by wakeup on 2018/6/22.
//  Copyright © 2018年 ourtoken. All rights reserved.
//

#import "WKLoadWalletCell3.h"
#import "WKBaseHeader.h"

@interface WKLoadWalletCell3 ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *privateEditText;//明文私钥
@property (weak, nonatomic) IBOutlet UILabel *placeholderLabel;//占位符
@property (weak, nonatomic) IBOutlet UIButton *startImportBtn;//开始导入按钮

@end

@implementation WKLoadWalletCell3

- (void)awakeFromNib {
    [super awakeFromNib];
    self.privateEditText.delegate = self;
    self.privateEditText.layer.borderColor = [AppManager.tableDetailColor CGColor];
    self.privateEditText.layer.borderWidth = 1;
    self.privateEditText.backgroundColor = [UIColor whiteColor];
    
    self.startImportBtn.backgroundColor = AppManager.themeColor;
    self.startImportBtn.titleLabel.font = AppManager.btnFont;
    self.startImportBtn.layer.cornerRadius = 5;
    self.startImportBtn.layer.masksToBounds = YES;
}

//开始导入
- (IBAction)clickStartImportBtn:(id)sender {
    if ([self.delegate respondsToSelector:@selector(startImportWallet3)]) {
        [self.delegate startImportWallet3];
    }
}

//UITextViewDelegate
- (void) textViewDidChange:(UITextView *)textView{
    if ([textView.text length] == 0) {
        [self.placeholderLabel setHidden:NO];
    }
    else{
        [self.placeholderLabel setHidden:YES];
    }
}

-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self endEditing:YES];
}


@end
